package edu.hitsz.application;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ModeSelect {
    private JPanel mode;
    private JButton easyButton;
    private JButton normalButton;
    private JButton hardButton;
    private JComboBox comboBox1;
    private JTextField userName;
    private JLabel userNameLabel;
    private JLabel musicLabel;
    private Object lock = new Object();
    private int modeType;
    private boolean musicSwitch;
    private String user;

    public ModeSelect() {
        easyButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                modeType = 1;
                musicSwitch = (comboBox1.getSelectedItem() == "开");
                user = userName.getText();
                synchronized (lock) {
                    lock.notify();
                }
            }
        });
        normalButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                modeType = 2;
                musicSwitch = (comboBox1.getSelectedItem() == "开");
                user = userName.getText();
                synchronized (lock) {
                    lock.notify();
                }
            }
        });
        hardButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                modeType = 3;
                musicSwitch = (comboBox1.getSelectedItem() == "开");
                user = userName.getText();
                synchronized (lock) {
                    lock.notify();
                }
            }
        });

    }

    public JPanel getPanel(){
        return this.mode;
    }

    public Object getLock(){ return this.lock; }

    public int getModeType() { return this.modeType; }

    public boolean getMusicSwitch() { return this.musicSwitch; }
    public String getUser() { return this.user; }
}
